﻿/*****************************************************************************
 *
 *	WUZEWEN Create on 2005-9-6,高级版用js文件,需要结合开发版的mainbody.js文件使用。
 *
 *****************************************************************************/

/**
 *	WUZEWEN ON 2005-8-8
 *	组合当前目录下的所有建表文件为一个表结构说明文件，类型为 html/doc
 */
function getSystemTableCreateHtml(){

	var tableChTokenizer="",tableNameTokenizer="";
	var h1Id=0,h2Id=0,h3Id=0;
	var createFileType="html" ;
	var colIdWidth=45,colChWidth=150,colEnWidth=120,colTypeWidth=135,colNullWidth=60,colDefaultWidth=60;
	//option:var colIdWidth=55,colChWidth=145,colEnWidth=115,colTypeWidth=130,colNullWidth=75,colDefaultWidth=75;
	if(createFileType=="doc"){
		colIdWidth=30,colChWidth=70,colEnWidth=70,colTypeWidth=110,colNullWidth=30,colDefaultWidth=30;
	}
	//--------------- 读取对象模型，将数据和显示风格分离[未全部]
	var ForWriting=2, ts0 ;
	var fso=getFSO();
	ts0 = fso.CreateTextFile( document.all.file_path.value+"/allTableCreate.html", true);
	var f1, ts,l_str; 
	var ForReading = 1; 

	//读取 xxx.html(.doc) 的模板
	try{
		ts = fso.OpenTextFile( clientSidePath+"model_AllTableCreateDoc_Creator.html" , ForReading);	//确保当前路径为本文件路径
		//alert(clientSidePath+"model_AllTableCreateDoc.html");
		//return;
	}catch(exp){
		alert("找不到模板文件啊:"+clientSidePath+"model_AllTableCreateDoc_Creator.html" 
					+ "\n\t请将/pda/jsp下面的model_AllTableCreateDoc.html文件拷贝过去再执行!");
		ts0.close();
		return;
	}
	var contentHead="",contentTail="" ;
	//读取首部并写入
	while( ts.AtEndOfStream != true ){
		l_str = ts.ReadLine();
		l_str = l_str.trim() ;
		ts0.WriteLine(l_str);
		if(l_str=="<!-- ModelBegin -->")
			break ; 
	}


	//用户变化的数据区	
	var folderPath = document.all.file_path.value ;
	var fldr = fso.GetFolder( folderPath ); 
	// 处理文件夹
		// todo...
	// 处理文件
	var fc = new Enumerator(fldr.files);
	var fileName = "";
	var tableId = 0 ;
	for (var i_2=0; !fc.atEnd(); fc.moveNext(),i_2++)
	{
		//获取文件名     
		fileName = fc.item() ;  
		fileName += "" ;
		if( !(fileName.trim().endsWith(".woo.table")) || fileName.trim().indexOf("_H__")>0 )
			continue ;
		//下面是针对生成报表的表结构详细设计做的过滤  -temp
		//if( fileName.trim().indexOf("FX_BB_BBCSXX")>0 || fileName.trim().indexOf("FX_BB_SJZDXX")>0 || fileName.trim().indexOf("FX_BB_")<0)
		//	continue ;

		//创建新的文件对象并且读取  rowCon 不使用 trim()函数
		var f1, ts,l_str, rowCon="";
		var outPos=-1 ;
		var ForReading = 1;
		ts3 = fso.OpenTextFile( fileName, ForReading); 
		
		//读取主键信息
		//循环写索引等信息
		var pk_Str = "";
		while( ts3.AtEndOfStream != true ){
			l_str = ts3.ReadLine();
			l_str = l_str.trim() ;
			if( l_str.indexOf("primary key")>0 ){
				pk_Str = l_str.substring(l_str.indexOf("(")+1, l_str.indexOf(")") ) ;	
				pk_Str = pk_Str.toLowerCase(); 
				break;
			}
		}
		ts3.Close() ;

	
		ts3 = fso.OpenTextFile( fileName, ForReading); 
		//通过 ts3读取文件内容如下：
		//定位
		var tableEn=fileName.substring(0,fileName.indexOf("___")),tableCh="";
		var colType="",colEn="",colCh="",colNull="";
		while( ts3.AtEndOfStream != true ){
			l_str = ts3.ReadLine();
			l_str = l_str.trim() ;
			if( l_str.indexOf("表名")>0 ){
				tableCh = l_str.substring( l_str.indexOf("表名:")+3,l_str.indexOf("*/") );
			}else if( l_str.indexOf("Table Name:")>0 ){
				tableCh = l_str.substring( l_str.indexOf("Table Name:")+11,l_str.indexOf("*/") );
			}
			//if( l_str.indexOf("]")>0 ){
			//	document.all.tableMkbh.value = l_str.substring( l_str.indexOf("[")+1, l_str.indexOf("]表名") );
			//}
			if(l_str=="(")
				break ;
		}
//写表头名称和标题行
var tableName="demotable" ;
tableName = tableEn.substring(fileName.lastIndexOf("\\")+1,fileName.indexOf("___"));
tableChTokenizer += tableCh +";";
tableNameTokenizer += tableName +";";



// 列表前内容
ts0.WriteLine( "  <p class=MsoBodyTextFirstIndent2><span lang=EN-US><o:p>&nbsp;</o:p></span></p>");
ts0.WriteLine( "  ");
ts0.WriteLine( "  <h5><![if !supportLists]><span lang=EN-US style='mso-fareast-font-family:\"Times New Roman\"'><span");
ts0.WriteLine( "  style='mso-list:Ignore'>2.4.1.1."+ ++h3Id +"<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
ts0.WriteLine( "  </span></span></span><![endif]><span style='font-family:宋体;mso-ascii-font-family:");
ts0.WriteLine( "  \"Times New Roman\";mso-hansi-font-family:\"Times New Roman\"'>表</span><span");
ts0.WriteLine( "  lang=EN-US>"+tableName+"</span></h5>");
ts0.WriteLine( "  ");
ts0.WriteLine( "  <div align=center>");
ts0.WriteLine( "  ");
ts0.WriteLine( "  <table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0");
ts0.WriteLine( "  style='border-collapse:collapse;border:none;mso-border-alt:solid windowtext 1.5pt;");
ts0.WriteLine( "  mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:.75pt solid windowtext;");
ts0.WriteLine( "  mso-border-insidev:.75pt solid windowtext'>");
ts0.WriteLine( "  <tr style='height:19.5pt;mso-row-margin-right:1.0pt'>");
ts0.WriteLine( "  <td width=72 style='width:53.75pt;border-top:1.5pt;border-left:1.5pt;");
ts0.WriteLine( "  border-bottom:1.0pt;border-right:1.0pt;border-color:windowtext;border-style:");
ts0.WriteLine( "  solid;mso-border-top-alt:1.5pt;mso-border-left-alt:1.5pt;mso-border-bottom-alt:");
ts0.WriteLine( "  .75pt;mso-border-right-alt:.75pt;mso-border-color-alt:windowtext;mso-border-style-alt:");
ts0.WriteLine( "  solid;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'>表</span><span lang=EN-US><span");
ts0.WriteLine( "  style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span></span><span");
ts0.WriteLine( "  style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";mso-hansi-font-family:");
ts0.WriteLine( "  \"Times New Roman\"'>名</span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td width=550 colspan=7 style='width:412.6pt;border-top:solid windowtext 1.5pt;");
ts0.WriteLine( "  border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.5pt;");
ts0.WriteLine( "  mso-border-left-alt:solid windowtext .75pt;mso-border-top-alt:1.5pt;");
ts0.WriteLine( "  mso-border-left-alt:.75pt;mso-border-bottom-alt:.75pt;mso-border-right-alt:");
ts0.WriteLine( "  1.5pt;mso-border-color-alt:windowtext;mso-border-style-alt:solid;padding:");
ts0.WriteLine( "  0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span lang=EN-US>"+tableName+"</span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td style='mso-cell-special:placeholder;border:none;padding:0cm 0cm 0cm 0cm'");
ts0.WriteLine( "  width=1><p class='MsoNormal'>&nbsp;</td>");
ts0.WriteLine( "  </tr>");
ts0.WriteLine( "  <tr style='height:19.5pt;mso-row-margin-right:1.0pt'>");
ts0.WriteLine( "  <td width=72 style='width:53.75pt;border-top:none;border-left:solid windowtext 1.5pt;");
ts0.WriteLine( "  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "  mso-border-top-alt:solid windowtext .75pt;mso-border-alt:solid windowtext .75pt;");
ts0.WriteLine( "  mso-border-left-alt:solid windowtext 1.5pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "  height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'>中文描述</span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td width=550 colspan=7 style='width:412.6pt;border-top:none;border-left:");
ts0.WriteLine( "  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.5pt;");
ts0.WriteLine( "  mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "  mso-border-alt:solid windowtext .75pt;mso-border-right-alt:solid windowtext 1.5pt;");
ts0.WriteLine( "  padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'>"+(tableCh.trim()=="XX表"?"":tableCh)+"</span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td style='mso-cell-special:placeholder;border:none;padding:0cm 0cm 0cm 0cm'");
ts0.WriteLine( "  width=1><p class='MsoNormal'>&nbsp;</td>");
ts0.WriteLine( "  </tr>");
ts0.WriteLine( "  <tr style='height:19.5pt;mso-row-margin-right:1.0pt'>");
ts0.WriteLine( "  <td width=72 style='width:53.75pt;border-top:none;border-left:solid windowtext 1.5pt;");
ts0.WriteLine( "  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "  mso-border-top-alt:solid windowtext .75pt;mso-border-alt:solid windowtext .75pt;");
ts0.WriteLine( "  mso-border-left-alt:solid windowtext 1.5pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "  height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'>功能说明</span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td width=550 colspan=7 style='width:412.6pt;border-top:none;border-left:");
ts0.WriteLine( "  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.5pt;");
ts0.WriteLine( "  mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "  mso-border-alt:solid windowtext .75pt;mso-border-right-alt:solid windowtext 1.5pt;");
ts0.WriteLine( "  padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'></span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td style='mso-cell-special:placeholder;border:none;padding:0cm 0cm 0cm 0cm'");
ts0.WriteLine( "  width=1><p class='MsoNormal'>&nbsp;</td>");
ts0.WriteLine( "  </tr>");
ts0.WriteLine( "  <tr style='height:19.5pt;mso-row-margin-right:1.0pt'>");
ts0.WriteLine( "  <td width=72 style='width:53.75pt;border-top:none;border-left:solid windowtext 1.5pt;");
ts0.WriteLine( "  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "  mso-border-top-alt:solid windowtext .75pt;mso-border-alt:solid windowtext .75pt;");
ts0.WriteLine( "  mso-border-left-alt:solid windowtext 1.5pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "  height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'>相关联的模块</span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td width=550 colspan=7 style='width:412.6pt;border-top:none;border-left:");
ts0.WriteLine( "  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.5pt;");
ts0.WriteLine( "  mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "  mso-border-alt:solid windowtext .75pt;mso-border-right-alt:solid windowtext 1.5pt;");
ts0.WriteLine( "  padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "  <p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "  mso-hansi-font-family:\"Times New Roman\"'></span></p>");
ts0.WriteLine( "  </td>");
ts0.WriteLine( "  <td style='mso-cell-special:placeholder;border:none;border-bottom:solid windowtext 1.0pt'");
ts0.WriteLine( "  width=1><p class='MsoNormal'>&nbsp;</td>");
ts0.WriteLine( "  </tr>");


//列说明信息
ts0.WriteLine( "<tr style='height:19.5pt'>");
ts0.WriteLine( "<td width=72 style='width:53.75pt;border-top:none;border-left:solid windowtext 1.5pt;");
ts0.WriteLine( "border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-alt:solid windowtext .75pt;");
ts0.WriteLine( "mso-border-left-alt:solid windowtext 1.5pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>列</span><span lang=EN-US><span");
ts0.WriteLine( "style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span></span><span");
ts0.WriteLine( "style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";mso-hansi-font-family:");
ts0.WriteLine( "\"Times New Roman\"'>名</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.1pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>中文描述</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=156 style='width:117.0pt;border-top:none;border-left:none;");
ts0.WriteLine( "border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "mso-border-alt:solid windowtext .75pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>数据类型（精度范围）</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=60 style='width:45.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>空</span><span lang=EN-US>/</span><span");
ts0.WriteLine( "style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";mso-hansi-font-family:");
ts0.WriteLine( "\"Times New Roman\"'>非空</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>默认值</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>是否自增</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>是否主键</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=47 colspan=2 style='width:35.5pt;border-top:none;border-left:none;");
ts0.WriteLine( "border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.5pt;");
ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "mso-border-alt:solid windowtext .75pt;mso-border-right-alt:solid windowtext 1.5pt;");
ts0.WriteLine( "background:#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>约束条件</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "</tr>");


//ts0.WriteLine("<h3 style='margin-left:90.0pt;text-indent:-81.0pt;mso-list:l0 level4 lfo1;");
//ts0.WriteLine("tab-stops:36.0pt'><![if !supportLists]><span lang=EN-US>1.<span");
//ts0.WriteLine("style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
//ts0.WriteLine("</span></span><![endif]><span lang=EN-US>2222222222</span></h3>");
 
 
		
		//循环写具体内容
		var i=0,j=0,note="",colNote="" ;
		var colId = 0 ;
		while( ts3.AtEndOfStream != true ){
			l_str = ts3.ReadLine();
			l_str = l_str.trim() ;
			if(l_str==")")
				break ;
			//2005-8-12 替换前获取column's colNote
			if(l_str.indexOf("[")>0){
				colNote = l_str.substring(l_str.indexOf("!")+1,l_str.indexOf("]"));
				l_str = l_str.substring(0,l_str.indexOf("[")) + l_str.substring(l_str.indexOf("]")+1);
			}else{
				colNote = "" ;
			}

			//l_str = l_str.replace(/,/g,"\t") ;			//替换 , 符号
			l_str = l_str.replace(/\t\t\t\t\t/g,"%");			//替换
			l_str = l_str.replace(/,\t\t\t\t/g,"%");
			
			l_str = l_str.replace(/\t\t\t\t/g,"%");			//替换
			l_str = l_str.replace(/,\t\t\t/g,"%");
			
			l_str = l_str.replace(/\t\t\t/g,"%");			//替换 ,\t\t || \t\t\t 符号
			l_str = l_str.replace(/,\t\t/g,"%");
			
			l_str = l_str.replace(/\t\t/g,"%");			//替换 \t\t 符号
			l_str = l_str.replace(/,\t/g,"%");	
			
			l_str = l_str.replace(/\t/g,"%") ;			//替换 \t 符号
			
			i=0 ;
			j = l_str.indexOf("%",0);   
			if(j==0){	// wzw on 2009-9-26
				i=1;
				j=l_str.indexOf("%",1); 
			}
			//alert(l_str);
			//alert(j);
			tablecols01 += l_str.substring(i,j) +"\n" ;
			colEn = l_str.substring(i,j) +"\n" ; 
			//alert(colEn); return ;

			i = ++j ;
			j = l_str.indexOf("%",i);
			tablecols02 += l_str.substring(i,j) +"\n" ;
			colType = l_str.substring(i,j) +"\n" ;
			
			i = ++j ;
			j = l_str.indexOf("%",i);
			tablecols05 += l_str.substring(i,j) +"\n" ;
			colNull= l_str.substring(i,j) +"\n" ;

			i = ++j ;
			j = l_str.indexOf("%",i);
			if(j<0) j = l_str.length ;
			var note = l_str.substring(i,j) ;	/* note */
			note = note.substring(3, note.length-3).trim();
			if(note.indexOf("uncheck")>0){
				tablecols04 += "\n" ;
				tablecols03 += note.substring(0, note.indexOf("uncheck")-1 ) + "\n" ;
				colCh = note.substring(0, note.indexOf("uncheck")-1 ) ;
			}else if( note.indexOf("check")>0 ){
				tablecols04 += note.substring(0, note.indexOf("check")-1 ) + "\n" ;
				tablecols03 += note.substring(0, note.indexOf("check")-1 ) + "\n" ;
				colCh = note.substring(0, note.indexOf("check")-1 ) ;
			}
			if(colNote!=""){
				colCh +="<br>"+colNote;
			}

		//某一个列
		ts0.WriteLine( "<tr style='height:19.5pt'>");
ts0.WriteLine( "<td width=72 style='width:53.75pt;border-top:none;border-left:solid windowtext 1.5pt;");
ts0.WriteLine( "border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-alt:solid windowtext .75pt;");
ts0.WriteLine( "mso-border-left-alt:solid windowtext 1.5pt;padding:0cm 5.4pt 0cm 5.4pt;");
ts0.WriteLine( "height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span lang=EN-US style='font-family:Courier;mso-fareast-font-family:");
ts0.WriteLine( "Courier;color:black;background:white;mso-highlight:white'>"+colEn.trim()+"</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.1pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>"+colCh+"</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=156 style='width:117.0pt;border-top:none;border-left:none;");
ts0.WriteLine( "border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;");
ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "mso-border-alt:solid windowtext .75pt;padding:0cm 5.4pt 0cm 5.4pt;height:");
ts0.WriteLine( "19.5pt'>");
ts0.WriteLine( "<p class=a2><span lang=EN-US style='font-family:Courier;mso-fareast-font-family:");
ts0.WriteLine( "Courier;color:red;background:white;mso-highlight:white'>"+colType.trim()+"</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=60 style='width:45.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>"+colNull.trim()+"</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span lang=EN-US><o:p>&nbsp;</o:p></span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span lang=EN-US><o:p>&nbsp;</o:p></span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=72 style='width:54.0pt;border-top:none;border-left:none;border-bottom:");
ts0.WriteLine( "solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-top-alt:");
ts0.WriteLine( "solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;mso-border-alt:");
ts0.WriteLine( "solid windowtext .75pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span lang=EN-US><o:p>&nbsp;</o:p>"+ (pk_Str.indexOf(colEn.trim().toLowerCase())>-1?"是":"")+"</span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "<td width=47 colspan=2 style='width:35.5pt;border-top:none;border-left:none;");
ts0.WriteLine( "border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.5pt;");
ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
ts0.WriteLine( "mso-border-alt:solid windowtext .75pt;mso-border-right-alt:solid windowtext 1.5pt;");
ts0.WriteLine( "padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
ts0.WriteLine( "<p class=a2><span lang=EN-US><o:p>&nbsp;</o:p></span></p>");
ts0.WriteLine( "</td>");
ts0.WriteLine( "</tr>"); 

		}

		//列循环完成
		ts0.WriteLine( "<tr style='mso-yfti-lastrow:yes;height:19.5pt;mso-row-margin-right:1.0pt'>");
		ts0.WriteLine( "<td width=72 style='width:53.75pt;border-top:none;border-left:solid windowtext 1.5pt;");
		ts0.WriteLine( "border-bottom:solid windowtext 1.5pt;border-right:solid windowtext 1.0pt;");
		ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-top-alt:.75pt;");
		ts0.WriteLine( "mso-border-left-alt:1.5pt;mso-border-bottom-alt:1.5pt;mso-border-right-alt:");
		ts0.WriteLine( ".75pt;mso-border-color-alt:windowtext;mso-border-style-alt:solid;background:");
		ts0.WriteLine( "#E0E0E0;padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
		ts0.WriteLine( "<p class=a2><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";");
		ts0.WriteLine( "mso-hansi-font-family:\"Times New Roman\"'>补充说明</span></p>");
		ts0.WriteLine( "</td>");
		ts0.WriteLine( "<td width=550 colspan=7 style='width:412.6pt;border-top:none;border-left:");
		ts0.WriteLine( "none;border-bottom:solid windowtext 1.5pt;border-right:solid windowtext 1.5pt;");
		ts0.WriteLine( "mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
		ts0.WriteLine( "padding:0cm 5.4pt 0cm 5.4pt;height:19.5pt'>");
		ts0.WriteLine( "<p class=a2><span lang=EN-US><o:p>&nbsp;</o:p></span></p>");
		ts0.WriteLine( "</td>");
		ts0.WriteLine( "<td style='mso-cell-special:placeholder;border:none;padding:0cm 0cm 0cm 0cm'");
		ts0.WriteLine( "width=1><p class='MsoNormal'>&nbsp;</td>");
		ts0.WriteLine( "</tr>");
		ts0.WriteLine( "<![if !supportMisalignedColumns]>");
		ts0.WriteLine( "<tr height=0>");
		ts0.WriteLine( "<td width=98 style='border:none'></td>");
		ts0.WriteLine( "<td width=72 style='border:none'></td>");
		ts0.WriteLine( "<td width=156 style='border:none'></td>");
		ts0.WriteLine( "<td width=60 style='border:none'></td>");
		ts0.WriteLine( "<td width=72 style='border:none'></td>");
		ts0.WriteLine( "<td width=72 style='border:none'></td>");
		ts0.WriteLine( "<td width=72 style='border:none'></td>");
		ts0.WriteLine( "<td width=46 style='border:none'></td>");
		ts0.WriteLine( "<td width=1 style='border:none'></td>");
		ts0.WriteLine( "</tr>");
		ts0.WriteLine( "<![endif]>");
		ts0.WriteLine( "</table>");
		ts0.WriteLine( "");
		ts0.WriteLine( "</div>");

	}

	//表汇总
ts0.WriteLine(" <h4><![if !supportLists]><span lang=EN-US style='mso-fareast-font-family:Arial;");
ts0.WriteLine(" mso-bidi-font-family:Arial'><span style='mso-list:Ignore'>2.4.1.2<span");
ts0.WriteLine(" style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
ts0.WriteLine(" </span></span></span><![endif]><span style='font-family:黑体;mso-ascii-font-family:");
ts0.WriteLine(" Arial'>表汇总</span></h4>");
ts0.WriteLine(" ");
ts0.WriteLine(" <div align=center>");
ts0.WriteLine(" ");
ts0.WriteLine(" <table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0");
ts0.WriteLine(" style='border-collapse:collapse;border:none;mso-border-alt:solid windowtext 1.5pt;");
ts0.WriteLine(" mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:.75pt solid windowtext;");
ts0.WriteLine(" mso-border-insidev:.75pt solid windowtext'>");


var posOri = 0,pos=0 ;
tableId = 0 ;
var tableEnArray = new Array();
var tableChArray = new Array();
//alert(tableNameTokenizer);
//alert(tableChTokenizer);
tableEnArray = tableNameTokenizer.split(";");
tableChArray = tableChTokenizer.split(";");
//while(tableChTokenizer.indexOf(";",posOri)>0 ){
for(var i=0; i<tableEnArray.length; i++){

	tableEn = tableEnArray[i] ;
	tableCh = tableChArray[i] ;
	if(tableCh.endsWith("表")){
		tableCh = tableCh.substring(0,tableCh.length-1).trim();
	}

	ts0.WriteLine( " <tr style='mso-yfti-lastrow:yes;height:16.5pt'>");
	ts0.WriteLine( " <td width=192 style='width:143.85pt;border-top:none;border-left:solid windowtext 1.5pt;");
	ts0.WriteLine( " border-bottom:solid windowtext 1.5pt;border-right:solid windowtext 1.0pt;");
	ts0.WriteLine( " mso-border-top-alt:solid windowtext .75pt;mso-border-top-alt:.75pt;");
	ts0.WriteLine( " mso-border-left-alt:1.5pt;mso-border-bottom-alt:1.5pt;mso-border-right-alt:");
	ts0.WriteLine( " .75pt;mso-border-color-alt:windowtext;mso-border-style-alt:solid;padding:");
	ts0.WriteLine( " 0cm 5.4pt 0cm 5.4pt;height:16.5pt'>");
	ts0.WriteLine( " <p class=a2><span lang=EN-US><span style='mso-spacerun:yes'>&nbsp;</span>"+tableEn+"</span></p>");
	ts0.WriteLine( " </td>");
	ts0.WriteLine( " <td width=94 valign=top style='width:70.7pt;border-top:none;border-left:none;");
	ts0.WriteLine( " border-bottom:solid windowtext 1.5pt;border-right:solid windowtext 1.0pt;");
	ts0.WriteLine( " mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
	ts0.WriteLine( " mso-border-alt:solid windowtext .75pt;mso-border-bottom-alt:solid windowtext 1.5pt;");
	ts0.WriteLine( " padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'>");
	ts0.WriteLine( " <p class=a2><span lang=EN-US><o:p>&nbsp;</o:p>"+(tableCh.trim()=="XX表"?"":tableCh)+"</span></p>");
	ts0.WriteLine( " </td>");
	ts0.WriteLine( " <td width=333 style='width:249.75pt;border-top:none;border-left:none;");
	ts0.WriteLine( " border-bottom:solid windowtext 1.5pt;border-right:solid windowtext 1.5pt;");
	ts0.WriteLine( " mso-border-top-alt:solid windowtext .75pt;mso-border-left-alt:solid windowtext .75pt;");
	ts0.WriteLine( " padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'>");
	ts0.WriteLine( " <p class=a2><span lang=EN-US><span style='mso-spacerun:yes'>&nbsp;</span></span></p>");
	ts0.WriteLine( " </td>");
	ts0.WriteLine( " </tr>"); 
}

ts0.WriteLine(" </table></div>");


	//去中间 temp
	while( ts.AtEndOfStream != true ){
		l_str = ts.ReadLine();
		if(l_str=="<!-- ModelEnd -->"){			
			ts0.WriteLine(l_str);
			break ; 
		}
	}
	//读取尾部
	while( ts.AtEndOfStream != true ){
		l_str = ts.ReadLine();
		l_str = l_str.trim() ;
		ts0.WriteLine(l_str);
	}
	ts.close();
	//---------------
	//alert(contentHead);
	//alert(contentTail);	
	ts0.Close() ;
	alert("生成文件成功！");
}